package org.rocky.provider.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Rocky
 * @date 2020/2/17 17:37
 */
@RequestMapping("/provider/fanout")
@RestController
public class SendFanoutController {

    private RabbitTemplate rabbitTemplate;


    @Autowired
    public SendFanoutController( RabbitTemplate rabbitTemplate){
        this.rabbitTemplate= rabbitTemplate;
    }

    /**
     * 发送广播消息
     * @return 页面
     */
    @RequestMapping("/sendFanoutMsg")
    public String rabbitSendFanout(){
        Map<String,Integer> map = new HashMap<>(16);
        map.put("cjy",22);
        map.put("tzl",22);
        rabbitTemplate.convertAndSend("FANOUT_EXCHANGE","",map);
        return "success";
    }
}
